// 引入接口文件
import { getMember } from './followupChartServ.js'

// 对象和JSON字符串互转
import { parse } from 'qs'
// 弹出消息框
import { message } from 'antd'
// 日期处理对象
import moment from 'moment'
/* isEmpty 对象是否为空
 * isArray 对象是否数组
 * cloneDeep 对象深拷贝
 */
import {isEmpty, isArray, cloneDeep, merge} from 'lodash'
// 引入路由对象
import { hashHistory } from 'dva/router'

// 初始默认状态
const defultState = {
  iFrameHeight:0,
  url:''
}

// 声明module
const tmpModule = {
  namespace: 'followupChartModel',
  // 默认状态
  state: cloneDeep(defultState),
  // 入口函数(先执行)
  subscriptions: {
    setup ({dispatch, history}) {
      history.listen(({ pathname, query }) => {
        // 页面路由匹配时执行
        if('' + tmpModule.pathname === '' + pathname){
          dispatch({
            type: `routergo`,
          });
        } // end if
      }) // end listen
    },
  },

  // 方法列表
  effects: {
    *updateModel({ payload }, { put, select }) {
      yield put({ type: 'updateStore', payload });
    },
    *routergo({ payload }, { put, select }){
      // console.log(document.body.scrollHeight,employeenumber)
      let url = `https://data.mideazy.com/bi/Viewer?proc=1&action=viewer&hback=true&db=!7f8e!!7684!!6848!!573a!!2f!!667a!!7f8e!!7f6e!!5bb6!!2f!!667a!1-!63a8!!4ecb!!53ca!!88ab!!63a8!!4ecb!!4eba!!8ddf!!8fdb!!60c5!!51b5!!8868!.db`
      window.open(url)
    }
  },

  // 存入状态机
  reducers: {
    updateStore(preState, action) {
      return Object.assign({}, preState, action.payload)
    },
  }
}

export default tmpModule
